// house_pkg/pages/room/index.ts
Page({
  data: {
  point: '',
  building: '',
  rooms: []
  },
  onLoad({point, building}) {
    // console.log(point, building);
    // 创建房间
    this.fake(point, building)
  },
  fake(point, building) {
    // 生成几个房间
    const size = Math.floor(Math.random() * 5) + 4
    const rooms = []
    for(let i = 0; i < size; i++){
      // 生成楼层号 1~20
      const floor = Math.floor(Math.random() * 19) + 1
      // 具体的房间号生成 1~3
      const No = Math.floor(Math.random() * 2) + 1
      //房间号为102，103的字符串 把房间号拼接成字符串
      const room = [floor, 0, No].join('')
      // 检测房间号是否重复
      if(rooms.includes(room)) return
      // 记录生成完整的房间号
      rooms.push(room)
    }
    // 渲染数据
    this.setData({rooms, point, building})
  }
})